package com.qf.controller;

import com.qf.entity.Company;
import com.qf.entity.Details;
import com.qf.service.CompanyService;
import com.qf.service.DetailsService;
import com.qf.service.impl.CompanyServiceImpl;
import com.qf.service.impl.DetailsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/*
杨威
2021/9/25
15:34
*/
@WebServlet("/showDetails")
public class ShowDetailsController extends HttpServlet {
    DetailsService detailsService=new DetailsServiceImpl();
    CompanyService companyService=new CompanyServiceImpl();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        List<Company> companyList = companyService.showCompany();
        Details details = detailsService.selectDetailsById(Integer.valueOf(id));
        request.setAttribute("details",details);
        request.setAttribute("companyList",companyList);
        request.getRequestDispatcher("/edit.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
